package com.why.rpc.core.common.serializable;



/**
 * @program: whyrpcframework
 * @description:使用什么方法进行序列化
 * @author: @why
 * @create: 2021-03-11 19:07
 **/
public interface CommonSerializable {
    /**
     *  //进行序列化
     * @param object
     * @return
     */
    byte[] serialize(Object object);

    /**
     * //反序列化
     * @param bytes
     * @param clazz
     * @return
     */
    public Object deserialize(byte[] bytes, Class<?> clazz);

    int getCode();
    static CommonSerializable getByCode(int code){
        switch (code){
            case 1:
                return new JsonSerializer();
            case 0:
                return new KroSerializer();
            default:
                return null;
        }

    }

}
